/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package backingBean;

import entites.Members;
import entities.Members;
import java.util.HashMap;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import manager.MembersManager;

/**
 *
 * @author ambaye
 */
@ManagedBean
@RequestScoped
public class Recherche {
List<Members> mesMembres;
     Members lemembre;

    public List<Members> getMesMembres() {
        return mesMembres;
    }

    public void setMesMembres(List<Members> mesMembres) {
        this.mesMembres = mesMembres;
    }

    public Members getLemembre() {
        return lemembre;
    }

    public void setLemembre(Members lemembre) {
        this.lemembre = lemembre;
    }

    public boolean isIsConnecte() {
         if (mesMembres != null && mesMembres.size() > 0) {
            isConnecte = true;
        } else {
            isConnecte = false;
        }
        return isConnecte;
    }

    public void setIsConnecte(boolean isConnecte) {
        this.isConnecte = isConnecte;
    }
    private String firstNameMembers;
    private String lastNameMembers;
    private int ageMembers;
    private List<Members> listeMembers;
    private boolean isConnecte;
    private String emailMembers;
//    @PostConstruct
//   public void InitData(){   
//       System.out.println("test1");
//      mesMembres=MembersManager.Affichertouslesmembres();
//      lemembre= new Members();
//
//    }
//  

    public String rechercherMembers() {
        HashMap mesListes = new HashMap();
     mesListes.put("isActive", 1);
         FacesMessage msg = null;
        if (firstNameMembers != null) {
            mesListes.put("firstNameMembers", "%" + firstNameMembers + "%");
           msg  = new FacesMessage("good");
        }
       
        if (lastNameMembers != null) {
            mesListes.put("lastNameMembers", "%" + lastNameMembers + "%");
             msg  = new FacesMessage("good");
        }
        if (emailMembers != null) {
            mesListes.put("emailMembers", "%" + emailMembers + "%");
        }

        mesListes.put("ageMembers", ageMembers);
       mesMembres = MembersManager.rechercheMembers(mesListes);
           
        return null;
    }

     public  void deleteMember(int idUser) {
        MembersManager.deleteMember(idUser);
//       rechercherMembers();
        
    }
    public Recherche() {
       HashMap mesListes = new HashMap();
        mesListes.put("isActive", 1);
        listeMembers = MembersManager.rechercheMembers(mesListes);
    }

    public String getFirstNameMembers() {
        return firstNameMembers;
    }

    public void setFirstNameMembers(String firstNameMembers) {
        this.firstNameMembers = firstNameMembers;
    }

    public String getLastNameMembers() {
        return lastNameMembers;
    }

    public void setLastNameMembers(String lastNameMembers) {
        this.lastNameMembers = lastNameMembers;
    }

    public int getAgeMembers() {
        return ageMembers;
    }

    public void setAgeMembers(int ageMembers) {
        this.ageMembers = ageMembers;
    }

    public List<Members> getListeMembers() {
       
        return listeMembers;
    }

    public void setListeMembers(List<Members> listeMembers) {
        this.listeMembers = listeMembers;
    }

    public String getEmailMembers() {
        return emailMembers;
    }

    public void setEmailMembers(String emailMembers) {
        this.emailMembers = emailMembers;
    }

//    public boolean isConnecte() {
//        if (mesMembres != null && mesMembres.size() > 0) {
//            isConnecte = true;
//        } else {
//            isConnecte = false;
//        }
//        return isConnecte;
//    }
//    
}
